﻿using System;

namespace EpiNEXT.Services.Validation.Functions
{
    public sealed class Hour : DateComponentBase
    {
        public Hour()
            : base()
        {

        }

        public override object Execute(Record record)
        {
            if (Parameters == null || Parameters.Count == 0 || Parameters[0] == null)
            {
                return null;
            }

            DateTime? date = GetDate(Parameters[0], record);

            if (date.HasValue)
            {
                return date.Value.Hour;
            }
            else
            {
                return null;
            }
        }
    }
}
